package com.content_module.activity;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.LinearSnapHelper;
import android.support.v7.widget.PagerSnapHelper;
import android.support.v7.widget.RecyclerView;

import com.content_module.R;
import com.content_module.R2;
import com.content_module.adapter.SnapHelperAdapter;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import component.fy.com.common_module.base.BaseActivity;
import component.fy.com.common_module.widget.SpaceItemDecoration;

public class SnapHelperAct extends BaseActivity {
    private static final String TAG = "SnapHelperAct";
    @BindView(R2.id.common_smart_refresh_layout_smart)
    SmartRefreshLayout smartRefreshLayout;
    @BindView(R2.id.common_smart_refresh_layout_recycler)
    RecyclerView recyclerView;

    private SnapHelperAdapter adapter;
    private List<String> list = new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.common_smart_refresh_layout;
    }

    @Override
    protected void initView() {
        smartRefreshLayout.setEnableRefresh(false);
        smartRefreshLayout.setEnableLoadMore(false);
        recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
        recyclerView.setHasFixedSize(true);
        recyclerView.addItemDecoration(new SpaceItemDecoration(0,0,20,0));
        PagerSnapHelper pagerSnapHelper = new PagerSnapHelper();
        LinearSnapHelper linearSnapHelper = new LinearSnapHelper();
        adapter = new SnapHelperAdapter(this, R.layout.content_item_image_only);
        recyclerView.setAdapter(adapter);
//        pagerSnapHelper.attachToRecyclerView(recyclerView);
        linearSnapHelper.attachToRecyclerView(recyclerView);
    }

    @Override
    protected void initEvents() {

    }

    @Override
    protected void initData() {
        list.add("http://d.hiphotos.baidu.com/image/pic/item/faf2b2119313b07e5119db2301d7912397dd8c71.jpg");
        list.add("http://a.hiphotos.baidu.com/image/pic/item/0dd7912397dda1449dd17697bfb7d0a20cf4863e.jpg");
        list.add("http://g.hiphotos.baidu.com/image/pic/item/0dd7912397dda1443b5c9090bfb7d0a20cf486bf.jpg");
        list.add("http://e.hiphotos.baidu.com/image/pic/item/728da9773912b31b549fe00b8b18367adab4e125.jpg");
        adapter.setData(list);
    }
}
